import {HTTP} from '@/config/site.coffee'
import ipc from '@/preload/ipc.coffee'
import {UserFetch} from '@/lib/req.coffee'

user = UserFetch ipc

export data_form = (data)=>
  opt = {
    method: 'POST'
  }
  if data
    formdata = new FormData()
    for [k,v] from Object.entries(data)
      formdata.append k,v
    opt.body = formdata
  opt

export post = (url, data)=>
  r = await upload url,data
  (await r.json()).data

export upload = (url, data)=>
  user.fetch(
    url
    data_form(data)
  )
